<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>指定范围生成随机数</title>
</head>
<body>
  <script>
    function fn(min, max) {
      return Math.floor(min + Math.random() * ((max + 1) - min))
    }
    console.log(fn(10, 20))
  </script>
</body>
</html>